import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


public class ReturnDigest extends Thread 
{
	private File input;
	private byte[] digest;
	
	public ReturnDigest(File input)
	{
		this.input = input;
	}
	
	public void run()
	{
		try {
			FileInputStream in = new FileInputStream(input);
			MessageDigest sha = MessageDigest.getInstance("SHA");
			DigestInputStream din = new DigestInputStream(in,sha);
			int b;
			while((b = din.read()) != -1);
			din.close();
			digest = sha.digest();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			System.err.println(e);
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			System.err.println(e);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			System.err.println(e);
		}
	}
	
	public byte[] getDigest()
	{
		return digest;
	}
}
